<template>
  <div class="contact-page">
    <h1>联系方式</h1>
    
    <div class="contact-split">
      <div class="contact-left">
        <div class="contact-info">
          <h3>联系信息</h3>
          <p>如果您有任何问题或合作意向，请随时通过以下方式联系我：</p>
          
          <div class="contact-methods-grid">
            <div v-for="(method, index) in contactMethods" :key="index" class="contact-method">
              <div class="contact-icon">
                <i :class="method.icon"></i>
              </div>
              <div class="contact-details">
                <h4>{{ method.title }}</h4>
                <p>{{ method.value }}</p>
              </div>
            </div>
          </div>
        </div>
        
        <div class="contact-form">
          <h3>发送消息</h3>
          <div class="form-group">
            <label for="name" class="form-label">姓名</label>
            <input type="text" id="name" v-model="form.name" class="form-input" placeholder="请输入您的姓名">
          </div>
          <div class="form-group">
            <label for="email" class="form-label">邮箱</label>
            <input type="email" id="email" v-model="form.email" class="form-input" placeholder="请输入您的邮箱">
          </div>
          <div class="form-group">
            <label for="subject" class="form-label">主题</label>
            <input type="text" id="subject" v-model="form.subject" class="form-input" placeholder="请输入消息主题">
          </div>
          <div class="form-group">
            <label for="message" class="form-label">留言内容</label>
            <textarea id="message" v-model="form.message" class="form-textarea" placeholder="请输入您的留言内容" rows="5"></textarea>
          </div>
          <button class="cta-button" @click="submitForm">
            <i class="fas fa-paper-plane"></i> 发送消息
          </button>
        </div>
      </div>
      
      <div class="contact-right">
        <div class="contact-map">
          <img 
            :src="mapImage" 
            alt="广州城市风景" 
            style="width:100%; height:100%; object-fit:cover;"
          >
          <div class="map-marker">
            <i class="fas fa-map-marker-alt"></i>
          </div>
        </div>
        
        <div class="social-section">
          <h3>社交媒体</h3>
          <p>你也可以通过以下社交媒体平台关注我：</p>
          <div class="social-links">
            <a v-for="(social, index) in socialLinks" 
               :key="index" 
               href="javascript:void(0)" 
               @click="showSocialQRCode(social)" 
               class="social-link">
              <i :class="social.icon"></i>
            </a>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加二维码弹窗组件 -->
    <div :class="['social-modal', {'active': showSocialModal}]" @click.self="closeSocialModal">
      <div class="social-modal-content">
        <div class="social-modal-header">
          <h3>{{ socialModalTitle }}</h3>
          <button class="close-button" @click="closeSocialModal">
            <i class="fas fa-times"></i>
          </button>
        </div>
        <div class="social-modal-body">
          <div class="qr-code-container">
            <img :src="socialModalImage" :alt="socialModalTitle + '二维码'" class="qr-code-image">
          </div>
          <p class="qr-code-hint">扫描上方二维码关注我</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getImagePath } from '../utils/imageHelper';

export default {
  data() {
    return {
      form: {
        name: '',
        email: '',
        subject: '',
        message: ''
      },
      contactMethods: [
        {
          title: '邮箱',
          value: 'pikario@qq.com',
          icon: 'fas fa-envelope'
        },
        {
          title: '电话',
          value: '+86 158 2057 8447',
          icon: 'fas fa-phone-alt'
        },
        {
          title: '地址',
          value: '广州白云',
          icon: 'fas fa-map-marker-alt'
        }
      ],
      socialLinks: [
        { 
          name: '微信', 
          icon: 'fab fa-weixin', 
          link: '#',
          image: getImagePath('wechat.jpg')
        },
        { 
          name: '小红书', 
          icon: 'fas fa-book',
          link: '#',
          image: getImagePath('xhs.jpg')
        },
        { 
          name: 'GitHub', 
          icon: 'fab fa-github', 
          link: 'https://gitee.com/kzc_666'
        }
      ],
      mapImage: getImagePath('GZtower.jpg'),
      showSocialModal: false,
      socialModalTitle: '',
      socialModalImage: ''
    }
  },
  methods: {
    submitForm() {
      // 这里可以实现表单提交逻辑
      console.log('表单提交:', this.form)
      alert('消息已发送！我们会尽快回复您。')
      
      // 清空表单
      this.form = {
        name: '',
        email: '',
        subject: '',
        message: ''
      }
    },
    showSocialQRCode(social) {
      if (social.image) {
        this.socialModalTitle = social.name;
        this.socialModalImage = social.image;
        this.showSocialModal = true;
        document.body.style.overflow = 'hidden'; // 防止背景滚动
      } else if (social.link && social.link !== '#') {
        window.open(social.link, '_blank');
      }
    },
    closeSocialModal() {
      this.showSocialModal = false;
      setTimeout(() => {
        document.body.style.overflow = ''; // 恢复背景滚动
      }, 400);
    }
  }
}
</script>

<style scoped>
.contact-page {
  margin-top: 40px;
}

.contact-split {
  display: flex;
  gap: 50px;
  margin-top: 30px;
}

.contact-left {
  flex: 1;
}

.contact-right {
  flex: 1;
}

.contact-info {
  margin-bottom: 40px;
  position: relative;
  padding: 30px 0;
}

/* 添加背景装饰 */
.contact-info:before {
  content: '';
  position: absolute;
  top: 0;
  left: -50px;
  right: -50px;
  height: 100%;
  background: linear-gradient(145deg, rgba(var(--primary-rgb), 0.03), rgba(var(--secondary-rgb), 0.03));
  border-radius: 15px;
  z-index: -1;
}

/* 将联系方式改为卡片网格布局 */
.contact-methods-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 25px;
}

.contact-method {
  background-color: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  gap: 15px;
}

.contact-method:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(67, 97, 238, 0.1);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.contact-icon {
  width: 45px;
  height: 45px;
  min-width: 45px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  transition: all 0.3s;
}

.contact-method:hover .contact-icon {
  background-color: var(--secondary-color);
  transform: scale(1.1);
}

.contact-details {
  flex: 1;
}

.contact-details h4 {
  margin: 0;
  margin-bottom: 5px;
  font-size: 1.1rem;
  color: var(--primary-color);
}

.contact-details p {
  margin: 0;
  color: #666;
  font-size: 0.95rem;
}

.contact-map {
  height: 400px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
  position: relative;
}

.map-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #e74c3c;
  font-size: 2.5rem;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, -65%);
  }
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.cta-button {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 30px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cta-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.social-section {
  margin-top: 30px;
}

.social-links {
  display: flex;
  gap: 15px;
  margin-top: 15px;
}

.social-link {
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  transition: all 0.3s;
  text-decoration: none;
}

.social-link:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

@media (max-width: 992px) {
  .contact-split {
    flex-direction: column;
  }
  
  .contact-left,
  .contact-right {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .social-links {
    flex-wrap: wrap;
  }
  
  .contact-methods-grid {
    grid-template-columns: 1fr;
  }
  
  .contact-info:before {
    left: -20px;
    right: -20px;
  }
}

/* 添加社交媒体弹窗样式 */
.social-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(23, 37, 85, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  backdrop-filter: blur(5px);
}

.social-modal.active {
  opacity: 1;
  visibility: visible;
}

.social-modal-content {
  background-color: white;
  border-radius: 15px;
  max-width: 350px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: translateY(30px) scale(0.95);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1), 
              opacity 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  overflow: hidden;
}

.social-modal.active .social-modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.social-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.social-modal-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  color: var(--primary-color);
}

.social-modal-body {
  padding: 25px;
  text-align: center;
}

.qr-code-image {
  max-width: 220px;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.qr-code-hint {
  margin-top: 15px;
  color: #666;
  font-size: 0.95rem;
}

/* 更新社交媒体弹窗关闭按钮样式 */
.social-modal .close-button {
  width: 36px;
  height: 36px;
  background-color: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: #555;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}

.social-modal .close-button:hover {
  background-color: var(--primary-color);
  color: white;
  transform: rotate(90deg);
}
</style> 